//导入第三方模块，mysql的第三方模块
const e = require('express');
const mysql = require('mysql');
const dateFormat = require('./dateFormat');

//创建一个连接数据库的桥梁
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'oamaniger'
});

//打开桥梁
connection.connect();

// 大壹接口

//查询车辆信息
module.exports.SelectCar = function (obj, callback) {
    // console.log(callback);
    let num = obj.CarNumber ? obj.CarNumber : '';
    let content = obj.CarDescript ? obj.CarDescript : '';
    let name = obj.UserName ? obj.UserName : '';
    let CarXz = obj.CarXz ? obj.CarXz : '';
    let bumen = obj.Department ? obj.Department : '';
    let sql = `select a.*,b.Department,c.UserName from carinfo a,departmentinfo b,userinfo c where
               a.DepartmentId=b.DepartmentId and c.UserGH=a.UserGH `;
    if (num) {
        sql += `and a.CarNumber like '%${num}%' `;
    }
    if (content) {
        sql += `and a.CarDescript like '%${content}%' `;
    }
    if (name) {
        sql += `and c.UserName like '%${name}%' `;
    }
    if (CarXz) {
        sql += `and a.CarXz like '%${CarXz}%' `;
    }
    if (bumen) {
        sql += `and b.Department like '%${bumen}%' `;
    }
    if (num == '' && content == '' && name == '' && CarXz == '' && bumen == '') {
        sql = sql
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}

//注册车辆的接口
module.exports.insertCar = function (cloumn, callback) {
    // console.log(cloumn);
    let sql = `insert into carinfo values(null,'${cloumn.UserGh}','${cloumn.CarNumber}','${cloumn.CarDescript}','${cloumn.CarXz}','${cloumn.DepartmentId}','${cloumn.Cartime}')`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}

//查询办公用品
module.exports.SelectOffice = function (obj, callback) {
    let num = obj.UserName ? obj.UserName : '';
    let content = obj.ThingName ? obj.ThingName : '';
    let name = obj.OFStatus ? obj.OFStatus : '';
    let sql = `select a.*,b.UserName from officeapplyinfo a,userinfo b where
   a.UserGH=b.UserGH`;
    if (num) {
        sql += ` and b.UserName like '%${num}%'`;
    }
    if (content) {
        sql += ` and a.ThingName like '%${content}%'`;
    }
    if (name) {
        sql += ` and a.OFStatus like '%${name}%'`;
    }
    if (num == "" && content == "" && name == "") {
        sql = sql
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//根据id修改审核状态
module.exports.UpdateOffice = function (cloumn, callback) {
    // console.log(cloumn);
    let sql = `update officeapplyinfo set OFStatus='${cloumn.OFStatus}',OAreason='${cloumn.OAreason}',Checker='${cloumn.Checker}' where Old='${cloumn.Old}'`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });
};
// 获取新闻信息
module.exports.SelectManage = function (callback) {
    let sql = `select * from newsinfo `;
    connection.query(sql, (err, data) => {
        callback(data)
    })
}
//通过id删除新闻
module.exports.DeleteMana = function (id, callback) {
    // console.log(id);
    let sql = `delete from newsinfo where NewsId = ${id}`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });
};
//创建新闻
module.exports.InsertMana = function (cloumn, callback) {
    console.log(cloumn.NewsTitle);
    let sql = `insert into newsinfo values(null,'${cloumn.NewsTitle}','${cloumn.NewsContent}','${cloumn.NewsTime}','${cloumn.NewsAuthor}','${cloumn.NewsPic}','${cloumn.LittleContent}')`;
    console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//员工
//获取日程安排
module.exports.getcalendarInfo = function (callback) {
    let sql = `select a.*,b.UserName from calendarinfo a,userinfo b where  a.UserGH=b.UserGH `;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//通过id删除行程
module.exports.DeletecalendarInfo = function (id, callback) {
    // console.log(id);
    let sql = `delete from calendarinfo where ClId = ${id}`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });
};
//创建日程
module.exports.InsertcalendarInfo = function (cloumn, callback) {
    // console.log(cloumn);
    let sql = `insert into calendarinfo values(null,'${cloumn.UserGH}','${cloumn.ClTitle}','${cloumn.Clcontent}','${cloumn.Cltime}')`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//获取工资信息
module.exports.Selectmoney = function (callback) {
    let sql = `select a.*,b.UserName from salaryinfo a,userinfo b where  a.UserGH=b.UserGH `;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//创建办公用品申请单
module.exports.Insertworkthing = function (cloumn, callback) {
    // console.log(cloumn);
    let sql = `insert into officeapplyinfo values(null,'${cloumn.UserGH}','${cloumn.ThingName}','${cloumn.ThingSum}','${cloumn.SQreason}','${cloumn.OAreason}','${cloumn.OFStatus}','${cloumn.Checker}')`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//获取消息的接口
module.exports.SelectEmil = function (coloum, callback) {
    let num = coloum.InformSender ? coloum.InformSender : '';
    let content = coloum.InformStatus ? coloum.InformStatus : '';
    // console.log(num);
    let sql = `select * from infrominfo `
    if (num != '' && content == '') {
        sql += ` where infrominfo.InformSender like '%${num}%'`;
    }
    if (content != '' && num == '') {
        sql += ` where infrominfo.InformStatus like '%${content}%'`;
    }
    if (content != '' && num != '') {
        sql += ` where infrominfo.InformStatus like '%${content}%' and infrominfo.InformSender like '%${num}%'`;
    }
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data)
    })
}
//根据id修改消息状态
module.exports.UpdateEmil = function (cloumn, callback) {
    // console.log(cloumn);
    let sql = `update infrominfo set InformStatus='${cloumn.InformStatus}' where InformId='${cloumn.InformId}'`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });
};
//通过id删除消息
module.exports.DeleteEmil = function (id, callback) {
    // console.log(id);
    let sql = `delete from infrominfo where InformId = ${id}`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });
};
//新增发送消息的接口
module.exports.InsertEmil = function (cloumn, callback) {
    // console.log(cloumn);
    let sql = `insert into infrominfo values(null,'${cloumn.InformCopyer}','${cloumn.InformSender}','${cloumn.InformTime}','${cloumn.InformContent}','${cloumn.InformStatus}')`;
    // console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    })
}



// 汪佳接口
//1.查寻个人信息，及账号密码
module.exports.personinfo = function (loginname, callback) {
    let sql = `select a.*,b.Department,c.Position from userinfo a,departmentinfo b,positioninfo c where a.UserGH='${loginname}' and a.DepartmentId=b.DepartmentId and a.PositionId=c.PositionId`;

    connection.query(sql, (err, data) => {
        callback(data)
    })
}
//2.根据登录名，查找权限目录
module.exports.manigernav = function (UserGH, callback) {
    let sql = `select a.UserName,c.* from userinfo a,departmentinfo b,things c where a.DepartmentId=b.DepartmentId and b.Departlevel=c.tlevel and a.UserGH='${UserGH}'`;
    console.log(sql);
    connection.query(sql, (err, datas) => {
        callback(datas)
    })
}
// 3.部门管理，新建部门
module.exports.add_part = function (body, callback) {
    let sql = `insert into departmentinfo values(null,'${body.department}','${body.partlevel}','备注')`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//4.查询所有部门
module.exports.allpart = function (callback) {
    let sql = `select * from departmentinfo`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//4.1根据部门id，查所有员工
module.exports.part_people = function (id, callback) {
    let sql = `select a.*,b.Department,c.Position from userinfo a,departmentinfo b,positioninfo c where a.DepartmentId='${id}' and a.DepartmentId=b.DepartmentId AND a.PositionId=c.positionid`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//5.根据id，删除部门
module.exports.delpart = function (id, callback) {
    let sql = `DELETE from departmentinfo where DepartmentId='${id}'`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//6.职位管理，新增职位
module.exports.add_position = function (body, callback) {
    let sql = `insert into positioninfo values(null,'${body.position}','${body.plevel}')`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//7.查询所有职位
module.exports.allposition = function (callback) {
    let sql = `select * from positioninfo`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//7.1根据职位id，查询所有人员
module.exports.position_people = function (id, callback) {
    let sql = `select a.*,b.Department,c.Position from userinfo a,departmentinfo b,positioninfo c where a.DepartmentId=b.DepartmentId AND a.PositionId=c.positionid and c.PositionId='${id}'`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//8.根据id，删除职位
module.exports.delposition = function (id, callback) {
    let sql = `DELETE from positioninfo where PositionId='${id}'`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//9.权限管理,新增部门权限
//9.权限管理,根据部门等级添加部门新权限
module.exports.add_power = function (body, callback) {
    var url = body.url ? body.url : '/newpower';
    let sql = `insert into things values(null,'${body.newpower}','${body.level}','${body.url}')`;
    connection.query(sql, function (err, datas) {
        callback(datas);
    })
}
//10.获取所有权限
module.exports.allpower = function (callback) {
    let sql = `select DISTINCT title,url from things`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
// 11.根据修改部门层级，查找所部门权限
module.exports.chosepower = function (level, callback) {
    let sql = `select * from things where tlevel='${level}'`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//12.删除部门权限
module.exports.delchosepower = function (level, callback) {
    let sql = `DELETE from things where tlevel='${level}'`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//13.查询所有员工信息
module.exports.alluser = function (callback) {
    let sql = `select * from userinfo`;
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}
//14.修改员工信息，和权限
module.exports.updatejob = function (body, callback) {
    let sql = `update userinfo set DepartmentId='${body.part}',PositionId='${body.positionid}' where UserGH='${body.UserGH}'`;
    console.log(sql);
    connection.query(sql, function (err, datas) {
        callback(datas)
    })
}







// 张家晨接口
// 1、员工管理
// 1.1 渲染员工信息
module.exports.allstaff = function (callback) {
    let sql = `select a.*,b.Position,c.Department from userinfo a,positioninfo b,departmentinfo c where a.PositionId=b.PositionId and a.DepartmentId=c.DepartmentId`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 1.2 员工工号、姓名模糊查询
module.exports.searchstaff = function (num, name, callback) {
    let sql = `select a.*,b.Position,c.Department from userinfo a,positioninfo b,departmentinfo c where a.PositionId=b.PositionId and a.DepartmentId=c.DepartmentId `;
    if (num) {
        sql += `and a.UserGH like '%${num}%'`;
    }
    if (name) {
        sql += `and a.UserName like '%${name}%'`;
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 1.3 修改写入员工信息
module.exports.changestaff = function (body, callback) {
    let sql = `update userinfo set PassWord='${body.PassWord}',Email='${body.Email}',PositionId='${body.PositionId}',DepartmentId='${body.DepartmentId}',Telephone='${body.Telephone}' where UserGH='${body.UserGH}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    });
}
// 1.4 删除员工信息
module.exports.delstaff = function (id, callback) {
    let sql = `delete from userinfo where UserGH='${id}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 1.5 新增员工信息
module.exports.addstaff = function (uinfo, callback) {
    let sextype = uinfo.sextype == '0' ? '男' : '女';
    switch (uinfo.positiontype) {
        case '0':
            positiontype = 1;
            break;
        case '1':
            positiontype = 2;
            break;
        default:
            positiontype = 3;
            break;
    }
    switch (uinfo.departmenttype) {
        case '0':
            departmenttype = 1;
            break;
        case '1':
            departmenttype = 2;
            break;
        default:
            departmenttype = 3;
            break;
    }
    let sql = `insert into userinfo values(null,'${uinfo.usergh}','${departmenttype}','${positiontype}','${uinfo.username}','${uinfo.password}','${sextype}','${uinfo.birthday}','${uinfo.idcard}','${uinfo.telephone}','${uinfo.address}','${uinfo.email}','${uinfo.userpic}','${uinfo.loginstate}')`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}

// 2、合同管理
// 2.1 渲染合同信息
module.exports.allcontract = function (callback) {
    let sql = `select a.*,b.UserName from hetonginfo a,userinfo b where a.UserGH = b.UserGH`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 2.2 员工姓名、其他模糊查询
module.exports.searchcontract = function (body, callback) {
    let name = body.name;
    let hetong = body.hetong;
    name = name ? name : '';
    hetong = hetong ? hetong : '';
    let sql = `select a.*,b.UserName from hetonginfo a,userinfo b where a.UserGH = b.UserGH `;
    if (name) {
        sql += `and b.UserName like '%${name}%'`;
    }
    if (hetong == 0) {
        sql += `and 1=1`;
    } else if (hetong == 1) {
        sql += `and a.HTStatus = '已到期'`;
    } else {
        sql += `and a.HTStatus = '续约中'`;
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 2.3 添加合同信息
module.exports.addcontract = function (htinfo, callback) {
    let sql = `insert into hetonginfo values(null,'${htinfo.pid}','${htinfo.usergh}','${htinfo.signtime}','${htinfo.starttime}','${htinfo.endtime}','${htinfo.htstatus}')`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 2.4 删除合同信息
module.exports.delcontract = function (id, callback) {
    let sql = `delete from hetonginfo where ContractId='${id}' and HTStatus='已到期'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}

// 3、请假管理
// 3.1 渲染请假合同
module.exports.allleave = function (callback) {
    let sql = `select a.*,b.UserName from qingjiainfo a,userinfo b where a.UserGH = b.UserGH`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 3.2 请假审批信息模糊查询
module.exports.searchleave = function (body, callback) {
    let { name } = body;
    if (body == 1) {
        sql = `select a.*,b.UserName from qingjiainfo a,userinfo b where a.UserGH = b.UserGH and QJStatus='同意'`;
    } else if (body == 2) {
        sql = `select a.*,b.UserName from qingjiainfo a,userinfo b where a.UserGH = b.UserGH and QJStatus='驳回'`;
    } else if (body == 3) {
        sql = `select a.*,b.UserName from qingjiainfo a,userinfo b where a.UserGH = b.UserGH and QJStatus='未审批'`;
    }else{
        sql = `select a.*,b.UserName from qingjiainfo a,userinfo b where a.UserGH = b.UserGH`;
    }
    name = name ? name : '';
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 3.3 渲染待审批列表
module.exports.allleave2 = function (callback) {
    let sql = `select a.*,b.UserName from qingjiainfo a,userinfo b where a.UserGH = b.UserGH and QJStatus='未审批'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 3.4 请假待审批
module.exports.dspleave = function (body, callback) {
    let sql = `update qingjiainfo set QJStatus='${body.QJStatus}',QJreson='${body.QJreson}',Checker='${body.Checker}' where Mid='${body.Mid}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}

// 4、工资管理
// 4.1 渲染工资信息
module.exports.allsalary = function (callback) {
    let sql = `select a.*,b.UserName from salaryinfo a,userinfo b where a.UserGH = b.UserGH`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 4.2 员工姓名模糊查询
module.exports.searchsalary = function (name, callback) {
    let sql = `select a.*,b.UserName from salaryinfo a,userinfo b where a.UserGH = b.UserGH `;
    if (name) {
        sql += `and b.UserName like '%${name}%'`
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 4.3 渲染工资发放列表
module.exports.showsalary = function (callback) {
    let sql = `select a.*,b.Department,c.Position from userinfo a,departmentinfo b,positioninfo c where a.DepartmentId = b.DepartmentId and a.PositionId = c.PositionId`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 4.4 职位模糊查询
module.exports.searchsalary2 = function (body, callback) {
    let { name } = body;
    name = name ? name : '';
    let sql = `select a.*,b.*,c.Department,d.Position from salaryinfo a,userinfo b,departmentinfo c,positioninfo d where a.UserGH = b.UserGH and b.DepartmentId = c.DepartmentId and b.PositionId = d.PositionId `;
    if (body == 0) {
        sql += `and d.Position = '部门经理'`;
    } else if (body == 1) {
        sql += `and d.Position = '员工'`;
    } else {
        sql += `and d.Position = '其他成员'`;
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 4.5 发放工资
module.exports.allsalary2 = function (sinfo, callback) {
    let sql = `insert into salaryinfo values(null,'${sinfo.UserGH}','${sinfo.increaseWages}','${sinfo.DecreaseWages}','${sinfo.BSalary}','${sinfo.Salary}','${sinfo.SDate}')`;
    connection.query(sql, (err, data) => {
        callback(data);
    });
}

// 5、培训管理
// 5.1 渲染培训信息
module.exports.alltrain = function (callback) {
    let sql = `select * from traininginfo`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 5.2 报名状态模糊查询
module.exports.searchtrain1 = function (body, callback) {
    let { name } = body;
    name = name ? name : '';
    if (body == 0) {
        sql = `select * from traininginfo where 1=1`;
    } else if (body == 1) {
        sql = `select * from traininginfo where PXStatus='已开始'`;
    } else {
        sql = `select * from traininginfo where PXStatus='已结束'`;
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 5.3 删除培训信息
module.exports.deltrain = function (id, callback) {
    let sql = `delete from traininginfo where PXId='${id}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 5.4 新建培训计划
module.exports.addtrain2 = function (tinfo, callback) {
    let sql = `insert into traininginfo values(null,'${tinfo.pxmz}','${tinfo.pxnr}','${tinfo.pxbegtime}','${tinfo.pxendtime}','${tinfo.pxdz}','${tinfo.pxstatus}')`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 5.5 渲染报名情况列表
module.exports.alltrain2 = function (callback) {
    let sql = `select a.*,b.UserName,c.* from traininginfo a,userinfo b,pxsqinfo c where a.PXId = c.PXId and b.UserGH = c.UserGH`;
    connection.query(sql, (err, data) => {
        callback(data);
    });
}
// 5.6 员工报名情况模糊查询 
module.exports.searchtrain = function (body, callback) {
    let name = body.name;
    let pxmc = body.pxmc;
    let pxstatus = body.pxstatus;
    name = name ? name : '';
    pxmc = pxmc ? pxmc : '';
    pxstatus = pxstatus ? pxstatus : '';
    let sql = `select a.*,b.UserName,c.* from traininginfo a,userinfo b,pxsqinfo c where a.PXId = c.PXId and b.UserGH = c.UserGH `;
    if (name) {
        sql += `and b.UserName like '%${name}%'`;
    }
    if (pxmc) {
        sql += `and a.PXName like '%${pxmc}%'`;
    }
    if (pxstatus) {
        if (pxstatus == 0) {
            sql += `and c.SqStatus = '未审批'`;
        } else if (pxstatus == 1) {
            sql += `and c.SqStatus = '同意'`;
        } else {
            sql += `and c.SqStatus = '驳回'`;
        }
    }
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 5.7 员工报名审核
module.exports.shtrain = function (body, callback) {
    let sql = `update pxsqinfo set SqStatus='${body.SqStatus}',SqReason='${body.SqReason}' where PXId='${body.PXId}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}


//员工界面接口
// 1.个人信息，修改个人信息接口
module.exports.changeself = function (body, callback) {
    let sql = `update userinfo set PassWord='${body.pwd}',Telephone='${body.phone}',Email='${body.email}',Address='${body.address}',UserPic='${body.pic}' where UserGH='${body.UserGH}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//.2.根据登录名查找请假信息
module.exports.person_rest = function (UserGH, callback) {
    let sql = `select * from qingjiainfo where UserGH='${UserGH}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//2.1通过id删除请假
module.exports.Del_rest = function (id, callback) {
    console.log(id);
    let sql = `delete from qingjiainfo where Mid = '${id}'`;
    console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });
};
//2.2新增个人请假条
module.exports.add_rest = function (body, callback) {
    console.log(body);
    let sql = `insert into qingjiainfo values(null,'${body.usergh}','${body.because}','${body.bigin}','${body.end}','${body.subtime}','${body.type}','主管写','未审批','审批人')`;
    console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    });

}

//3合同信息，查询个人合同信息
module.exports.personhetong = function (usergh, callback) {
    let sql = `select a.*,b.UserName from hetonginfo a,userinfo b where a.UserGH = b.UserGH and a.userGH='${usergh}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 3.2 员工姓名、其他模糊查询
module.exports.searchcontract1 = function (body, callback) {
    let name = body.name;
    let hetong = body.hetong;
    name = name ? name : '';
    hetong = hetong ? hetong : '';
    console.log(hetong);
    let sql = `select a.*,b.UserName from hetonginfo a,userinfo b where a.UserGH = b.UserGH `;
    if (name) {
        sql += `and b.UserName like '%${name}%'`;
    }
    if (hetong == 0) {
        sql += `and 1=1`;
    } else if (hetong == 1) {
        sql += `and a.HTStatus = '已到期'`;
    } else {
        sql += `and a.HTStatus = '续约中'`;
    }
    console.log(sql);
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
// 4.个人培训申请纪律
module.exports.persontrain = function (usergh, callback) {
    let sql = `SELECT * FROM pxsqinfo WHERE userGH='${usergh}'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//4.1.查询所有可报名的培训项目
module.exports.trainok = function (callback) {
    let sql = `select * from traininginfo where PXStatus='报名开始'`;
    connection.query(sql, (err, data) => {
        callback(data);
    })
}
//4.2新建培训报名申请
module.exports.add_trainsq = function (body, callback) {
    let sql = `insert into pxsqinfo values(null,'${body.usergh}','${body.because}','未审批','${body.pxid}')`;
    connection.query(sql, (err, data) => {
        callback(data);
    });
}